package com.cdtu.outtake.config;

import com.cdtu.outtake.interceptor.CorsInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author : shl
 * @Date 2024/3/2 22:17
 */
@Configuration
@RequiredArgsConstructor
public class MyConfiguration implements WebMvcConfigurer {
    private final CorsInterceptor corsInterceptor;

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(corsInterceptor).addPathPatterns("/**");
    }
}
